const mongoose = require('mongoose');

const publicModelSchema = new mongoose.Schema({
    name: {
        type: String,
        required: true,
        trim: true
    },
    description: {
        type: String,
        default: ''
    },
    uploadedBy: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'User',
        required: true
    },
    file: {
        fileName: String,
        filePath: String,
        fileSize: Number,
        fileType: {
            type: String,
            enum: ['stl', 'obj'],
            required: true
        },
        uploadDate: {
            type: Date,
            default: Date.now
        }
    },
    thumbnail: {
        path: String,
        url: String
    },
    downloadCount: {
        type: Number,
        default: 0
    },
    createdAt: {
        type: Date,
        default: Date.now
    }
});

module.exports = mongoose.model('PublicModel', publicModelSchema);